<%@ Import Namespace="System.Data.SqlClient" %>

<script language="VB" runat="server">

  Sub Page_Load(Sender As Object, E As EventArgs)
  
    If Not Page.IsPostBack Then
        state.Items.Add("CA")
        state.Items.Add("IN")
        state.Items.Add("KS")
        state.Items.Add("MD")
        state.Items.Add("MI")
        state.Items.Add("OR")
        state.Items.Add("TN")
        state.Items.Add("UT")
    End If
   
  End Sub

  Sub ShowAuthors(Sender As Object, E As EventArgs)
  
    Dim con As New SqlConnection("Data Source=.; Initial Catalog=pubs; UID=sa; PWD=aido")
    Dim cmd As SqlCommand
    Dim qry As String
    
    con.Open()
    
    qry = "select * from authors where state='" & state.SelectedItem.Text & "'"
    cmd = New SqlCommand(qry, con)
    
    DataGrid1.DataSource = cmd.ExecuteReader()
    DataGrid1.DataBind()
    
    con.Close()
  
  End Sub
  
</script>

<form runat="server">

  State: <asp:DropDownList id="state" runat="server" />
  
  <asp:Button Text="Show Authors" OnClick="ShowAuthors" runat="server"/>

  <p/>  
  <asp:DataGrid id="DataGrid1" runat="server"/>

</form>